
package Lab6;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

public class UrrunekoAurkezpena extends JFrame {
  BorderLayout borderLayout1 = new BorderLayout();
  JPanel jPanel1 = new JPanel();
  JLabel jLabel1 = new JLabel();
  JLabel jLabel2 = new JLabel();
  JTextField jTextField1 = new JTextField();
  JPasswordField jPasswordField1 = new JPasswordField();
  JButton jButton1 = new JButton();
  UrrunekoNegozioLogikaInterfazea nlInt;
  JLabel jLabel3 = new JLabel();

  public UrrunekoAurkezpena() {
    super();
    try  {
      jbInit();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void jbInit() throws Exception {
    this.getContentPane().setLayout(borderLayout1);
    this.setSize(new Dimension(400, 300));
    jLabel1.setText("Idatzi erabiltzaile izena:");
    jLabel1.setBounds(new Rectangle(30, 50, 152, 32));
    jLabel2.setBounds(new Rectangle(55, 95, 113, 32));
    jTextField1.setBounds(new Rectangle(181, 50, 164, 31));
    jPasswordField1.setBounds(new Rectangle(180, 95, 163, 32));
    jButton1.setText("Sisteman sartu");
    jButton1.setBounds(new Rectangle(102, 145, 183, 36));
    jLabel3.setBounds(new Rectangle(42, 215, 326, 31));
    jButton1.addActionListener(new java.awt.event.ActionListener() {

      public void actionPerformed(ActionEvent e) {
        jButton1_actionPerformed(e);
      }
    });
    jLabel2.setText("Idatzi passworda:");
    jPanel1.setLayout(null);
    this.setTitle("Hau aurkezpen maila da");
    this.getContentPane().add(jPanel1, BorderLayout.CENTER);
    jPanel1.add(jLabel2, null);
    jPanel1.add(jLabel1, null);
    jPanel1.add(jTextField1, null);
    jPanel1.add(jPasswordField1, null);
    jPanel1.add(jButton1, null);
    jPanel1.add(jLabel3, null);
  }

  public void setNegozioLogika(UrrunekoNegozioLogikaInterfazea i) { //Lehen EZ URRUNEKOA
    nlInt=i;
  }

  void jButton1_actionPerformed(ActionEvent e) {
    try{
      boolean b = nlInt.loginEgin(jTextField1.getText(),new String (jPasswordField1.getPassword()));
      if (b) jLabel3.setText("AURRERA");
      else jLabel3.setText("EZ DUZU SARTZEKO BAIMENIK");
    }
    catch (Exception ex) {jLabel3.setText("NEGOZIO LOGIKAREKIN ARAZOAK DAUDE");}
  }
}


